home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sword.eng.pyramid.com!pyrltd!markb
- From: markb@pyramid.com (Mark Bluemel)
- Subject: Re: operator % - compiler error
- Message-ID: <1996Mar22.142327.17591@pyra.co.uk>
- Sender: news@pyra.co.uk
- Organization: Pyramid Technology Ltd.
- X-Newsreader: TIN [version 1.2 PL2]
- References: <4ihuuh$6ul@hatathli.csulb.edu> <DoH503.Hu7@iquest.net>
- Date: Fri, 22 Mar 1996 14:23:27 GMT
-
- Doug Miller (dlmiller@iquest.net) wrote:
- : davidcho@csulb.edu (David Cho) wrote:
-
- [Complete headers of quoted posting snipped...]
-
- : +When I try to compile, I get an erro message for the following line:
- : +
- : +
- : +x=663608941*y%pow(2,32) /*I want remainder*/
- : +
- : +But the error message says "illegal use of floating point". What does
- : +that mean? Isn't % used a an operator to calcuate the remainder?
-
- : You're right that % is the modulo operator.
-
- [Next block of text reformatted to < 78 characters per line]
- : Hard to say for sure what caused the error, as you have not posted the
- : declarations of x and y. But here are some suggestions. Remember that * is
- : the indirection operator, as well as the multiplication operator; try
- : putting spaces before and after the * so the compiler knows what you mean.
- : Do the same with the % operator. And remember you need a semicolon at the
- : end of your statement.
-
- I disagree with all the reply Doug gave, except perhaps his comment about the
- semicolon. The problem is almost certainly that % gives the remainder after
- *integer* division, and expects both operands to be integers.... pow() takes
- *doubles* as arguments and returns a *double*.
-
- As Doug says, we don't know what x and y are declared as - presumably doubles
- as AFAIK y%pow(2,32) wouldn't give anything useful with normal integer
- datatypes (assuming an implementation limit of 32 bits for integers). I'm
- afraid that % isn't usable here - could David post more details of what he's
- trying to achieve?
-
- --
- Mark Bluemel Unix/Oracle Trainer and Consultant
- My opinions are my own, but I'll share them
- All solutions to problems are offered "as is"
- and without warranty - you have been warned :-)
-